# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: omni <omni+alpine@hack.org>
pkgname=ocaml-findlib
_pkgname=findlib
pkgver=1.9.6
pkgrel=2
pkgdesc="OCaml package manager"
url="http://projects.camlcity.org/projects/findlib.html"
arch="all !riscv64" # ocaml
license="MIT"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml"
makedepends="ocaml-compiler-libs ocaml-ocamldoc m4 ncurses-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="http://download.camlcity.org/download/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

# 32bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	./configure \
		-bindir /usr/bin \
		-mandir /usr/share/man \
		-sitelib /usr/lib/ocaml \
		-config /etc/$_pkgname.conf \
		-no-camlp4
	make -j1 all opt
}

package() {
	make install prefix="$pkgdir"

	mkdir -p "$pkgdir"/usr/share/doc/$_pkgname/
	install -m 644 doc/README doc/QUICKSTART \
		"$pkgdir"/usr/share/doc/$_pkgname/
}

dev() {
	local sitelib="usr/lib/ocaml/$_pkgname"

	default_dev

	cd "$pkgdir"
	mkdir -p "$subpkgdir"/$sitelib
	mv $sitelib/*.cmxa \
		$sitelib/*.mli \
		$sitelib/Makefile.config \
		$sitelib/Makefile.packages \
		"$subpkgdir"/$sitelib/
}

sha512sums="
cfaf1872d6ccda548f07d32cc6b90c3aafe136d2aa6539e03143702171ee0199add55269bba894c77115535dc46a5835901a5d7c75768999e72db503bfd83027  findlib-1.9.6.tar.gz
"
